/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-06-26 18:55:04
 * @LastEditTime: 2024-08-22 22:06:54
 * @FilePath: /nest_study/server/src/modules/system/menu/dto/index.dto.ts
 */
import { ApiProperty, PartialType } from "@nestjs/swagger";
import { IsArray, IsEnum, IsNumber, IsOptional, IsString, Length } from "class-validator";
import { BaseInfoDto } from "src/common/dto/index.dto";
import { MenuTypes } from "src/common/enum/menu";

export class CreateMenuDto extends BaseInfoDto {
    @ApiProperty({ required: true })
    @IsNumber()
    parentId: number

    @ApiProperty({ required: true })
    @IsString()
    @Length(0, 20)
    name: string

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    path: string

    @ApiProperty({ required: true })
    @IsString()
    external: string

    @ApiProperty({ required: true })
    @IsString()
    visible: string

    @ApiProperty({ required: true })
    @IsString()
    @IsEnum(MenuTypes)
    menuType: string

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    perms: string

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    icon: string
}
export class UpdateMenuDto extends PartialType(CreateMenuDto) {
    @ApiProperty({ required: true })
    @IsNumber()
    id: number
    
    @IsArray()
    @IsOptional()
    children:Array<any>
}


export class DeleteMenuDto {
    @ApiProperty({
        required: false
    })
    @IsArray()
    @IsOptional()
    ids: number[]
}

export class QueryMenuDto {
    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    @Length(0, 20)
    name?: string;
}